<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>侦听器-immediate参数</title>
  <script src="vue.js"></script>
</head>
<body>
  <script>
    let circle = {
      position: {
        x:0, y:0
      },
      position2: {
        x:0, y:0
      }
    }
    let vm = new Vue({
      data: circle,
      watch: {
        position: {
          handler(value) {
            this.position2.x = this.position.x + Math.random();
            this.position2.y = this.position.y + Math.random();
            console.log(this.position2.x, this.position2.y);
          },
          deep: true,
          immediate: true
        }
      }
    });
    vm.position.x = 3; 
  </script>
</body>
</html>
